/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.calculator;

import boundless.entities.*;
import java.util.List;
import boundless.ejb.*;


/**
 *
 * @author hendrikdekock
 */
public class TeamStatCalculator {
    
    RequestBean rb;
    
    public TeamStatCalculator(RequestBean rb) {
        this.rb = rb;
    }
    
    public void setReqBean(RequestBean rb) {
        this.rb = rb;
    }
    
    public int calculateTeamPoints(List<Player> players) {
        int defensePoints = 0;
        int kickingPoints = 0;
        int offensePoints = 0;
        for(Player p: players) {
            if (p.getPlayposition().getId() == Playposition.DEFENSE) {
                defensePoints = DefensePlayerCalculator.calculate(rb.getPlayerStats(p));
            }
            else if (p.getPlayposition().getId() == Playposition.KICKER) {
                kickingPoints = KickingPlayerCalculator.calculate(rb.getPlayerStats(p));
            }
            else {
                offensePoints += OffensePlayerCalculator.calculate(rb.getPlayerStats(p));
            }
        }
        return defensePoints + kickingPoints + offensePoints;
                
    }
    
}
